<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
  <style>
    .header{
      position: absolute;
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script>
   /*  const directives={
      focus:{
        mounted(el){
          el.focus()
        }
      }
    } */
    const app = Vue.createApp({
      // directives,
      mounted(){
        // this.$refs.input.focus();
      },
      data(){
        return{
          distance:200
        }
      },
    
      // template:`<input ref="input"/>`
      // template:`<input v-focus/>`
      template:`<div v-pos:left="distance" class="header"><input/></div>`
    });
    app.directive('pos',(el,binding)=>{
      el.style[binding.arg]=(binding.value+'px')
    })
    /* app.directive('pos',{
      beforeMount(el){
        console.log('beforeMount');
      },
      mounted(el,binding){
        console.log('mounted');
        // el.focus()
        el.style.top=(binding.value+'px')
      },
      beforeUpate(){
        console.log('beforeUpdate');
      },
      updated(el,binding){
        console.log('updated');
        el.style.top=(binding.value+'px')
      },
      beforeUnmount(){
        console.log('beforeUnmount');
      },
      unmounted(){
        console.log('unmounted');
      }
    }) */
   
    const vm = app.mount('#root');
  </script>
</body>

</html>